
#define LCD_SUPPLY_PIN 0x0100
#define LCD_SUPPLY_PORT 'B' //RB8
#define SUPPLY_5V_PIN 0x0004
#define SUPPLY_5V_PORT 'B' //RB2
#define LCD_BACKLIGHT_PIN 0x0001
#define LCD_BACKLIGHT_PORT 'D' //RD0
#define LCD_CS1_PIN 0x0004
#define LCD_CS1_PORT 'C' //RC2
#define LCD_A0_PIN 0x0020
#define LCD_A0_PORT 'B'  //RB5
#define LCD_RESET_PIN 0x0002
#define LCD_RESET_PORT 'C'  //RC2
#define COIL_1_PIN 0x0001
#define COIL_1_PORT 'G'	//RG0
#define COIL_2_PIN 0x0002
#define COIL_2_PORT 'G'	//RG1
#define MAX668SD_PIN 0x0400
#define MAX668SD_PORT 'B' //RB10
#define CS_MCP6S21_IN_PIN 0x0200
#define CS_MCP6S21_IN_PORT 'B'// RB9 /CS del MCP6S21 dello stadio di ingresso elettrodi(logica negata) --- chiamata funzioni: cs=0
#define CS_MCP6S21_COIL_PIN 0x0001
#define CS_MCP6S21_COIL_PORT 'F' // RF0  /CS del MCP6S21 del feedback della corrente bobine (logica negata) --- chiamata funzioni: cs=1
#define P_OUT_PIN 0x0002
#define P_OUT_PORT 'F'
#define GP_OUT_PIN 0x0040
#define GP_OUT_PORT 'B'
#define B1_PIN 0x1000
#define B1_PORT 'G'
#define B2_PIN 0x2000
#define B2_PORT 'G'
#define B3_PIN 0x4000
#define B3_PORT 'G'
#define B4_PIN 0x0100
#define B4_PORT 'D'




void PinOn(unsigned int pinX,unsigned char portX);
void PinOff(unsigned int pinX,unsigned char portX);
void UsDelay(long int us);
void actPos(void);
void actNeg(void);
void disCoil(void);
void PulseCounter(float add);
unsigned int GainSetup(unsigned short position,unsigned short device);
unsigned short ButtonsHandler(unsigned short AutoInc);
unsigned short PinIn(unsigned int pinX,unsigned short portX);
void Calculate420(float PInst, float PFullScale);
float GetPulseQty();
void SetPulseQty(float PQ);
float StartStop(float AccCount);
void LCDinitFast(void);
void BytesToULong(unsigned char *b,unsigned long int *out);